package com.ai.adapter.rest;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * 阿里云通义
 * @author wuchen
 */
@FeignClient(name = "tong", url = "https://dashscope.aliyuncs.com")
@RequestMapping("/api/v1/services/aigc")
public interface AliTonyYiRest {
    /**
     * 多轮对话
     * @param param
     * @return
     */
    @PostMapping("/text-generation/generation")
    Object doChat(@RequestBody DoChatParam param, @RequestHeader("Authorization") String authorization);

    /**
     * 多轮对话请求参数
     */
    @Data
    class DoChatParam{
        /**
         * 模型
         */
        private String model;
        /**
         * 输入
         */
        private DoChatInputParam input;

        /**
         * 相关参数
         */
        private DoChatParametersParam parameters;


    }

    /**
     * 输入对象
     */
    @Data
    class DoChatInputParam{
        private List<DoChatMessageParam> messages;
    }

    /**
     * 全部的消息集合
     */
    @Data
    class DoChatMessageParam{
        /**
         * 角色
         */
        private String role;
        /**
         * 内容
         */
        private String content;
    }

    /**
     * 请求相关参数
     */
    @Data
    class DoChatParametersParam{
        @JsonProperty("result_format")
        private String resultFormat;
    }

    class DoChatResultDto{

    }

}
